package com.yupi.springbootinit.model.vo;

import cn.hutool.json.JSONUtil;
import com.yupi.springbootinit.model.entity.PeripheralInfo;
import com.yupi.springbootinit.model.entity.Permission;
import com.yupi.springbootinit.model.entity.Post;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 帖子视图
 *

 */
@Data
public class PeripheralInfoVO implements Serializable {

    private Long id;

    /**
     * 名称
     */
    private String name;

    /**
     * 图片
     */
    private String cover;

    /**
     * 价格（分）
     */
    private Integer price;

    /**
     * 库存
     */
    private Integer stock;

    /**
     * 周边类型
     */
    private String type;

    /**
     * 用户购买链接
     */
    private String purchaseLink;

    /**
     * 是否公开浏览，0: 关闭，1: 启用，默认关闭
     */
    private Integer status;

    /**
     * 包装类转对象
     *
     * @param peripheralInfoVO
     * @return
     */
    public static PeripheralInfo voToObj(PeripheralInfoVO peripheralInfoVO) {
        if (peripheralInfoVO == null) {
            return null;
        }
        PeripheralInfo peripheralInfo = new PeripheralInfo();
        BeanUtils.copyProperties(peripheralInfoVO, peripheralInfo);
        return peripheralInfo;
    }

    /**
     * 对象转包装类
     *
     * @param peripheralInfo
     * @return
     */
    public static PeripheralInfoVO objToVo(PeripheralInfo peripheralInfo) {
        if (peripheralInfo == null) {
            return null;
        }
        PeripheralInfoVO peripheralInfoVO = new PeripheralInfoVO();
        BeanUtils.copyProperties(peripheralInfo, peripheralInfoVO);
        return peripheralInfoVO;
    }
}
